﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GWModflow.FileLayers
{
   public class PRecharge:Package
    {

       public PRecharge()
       {
           this._fileType = FileType.RCH;

           this.Nunit = 46;
           this.Fname = "solution.rch";




       }

       int _NRCHOP;


       /// <summary>
       /// 补给选项 1 ，2 ，3
       /// </summary>
       public int NRCHOP
       {
           get { return _NRCHOP; }
           set { _NRCHOP = value; }
       }


       int _IRCHCB = 106;

       /// <summary>
       /// cellbycell 标志位
       /// </summary>
       public int IRCHCB
       {
           get { return _IRCHCB; }
           set { _IRCHCB = value; }
       }


       List<SPRecharge> _stressPeriodCharges = new List<SPRecharge>();


       /// <summary>
       /// 逐选项值
       /// </summary>
       public List<SPRecharge> StressPeriodCharges
       {
           get { return _stressPeriodCharges; }
          
       }



    



       public override void WriteFile(string path)
       {
           string content = "# HuanAnKeJi RCH File" + "\r\n";
           content += this.NRCHOP + "  " + this.IRCHCB + "             Item 2: NRCHOP IRCHCB" + "\r\n";
           string str="";
           foreach (SPRecharge sp in this.StressPeriodCharges)
           {
               str += sp.INRECH + "  " + sp.INIRCH + "          Item 2:  INRECH INIRCH" + "\r\n";            
               string str1 = "";
               if (sp.INRECH >= 0)
               {
                   if (IsConstant(sp.RECH))
                   {
                       str += "CONSTANT " + string.Format("{0,10}", sp.RECH[0, 0]) + "\r\n";
                   }
                   else
                   {
                       str += "INTERNAL   1.0 (FREE)  19" + "\r\n";
                       if (GetArrayString(sp.RECH, ref  str1))
                       {
                           str += str1;
                       }
                   }


               }           
              
               string str2 = "";
               if (sp.INIRCH >= 0 && this .NRCHOP ==2)
               {   
                   if (IsConstant(sp.IRCH))
                   {
                       str += "CONSTANT " + string.Format("{0,10}", sp.IRCH[0, 0]) + "\r\n";
                   }
                   else
                   {
                       str += "INTERNAL   1.0 (FREE)  9" + "\r\n";
                       if (GetArrayString(sp.IRCH, ref  str2))
                       {
                           str += str2;
                       }
                   }
               }            
           }
           content += str;

           string fname = path + this.Fname;
           FXnaInfrastructure.FileHelper.WriteFile(fname, content);
       }




    }
}
